package ${package}.application;

import com.baomidou.mybatisplus.core.metadata.IPage;
import ${package}.entity.${className}DTO;
import ${package}.entity.${className}Query;
import ${package}.service.I${className}Service;
import ${package}.po.${className};
import ${package}.utils.BeanUtil;
import ${package}.vo.${className}VO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;


/**
 * ${className}应用层
 *
 * @author ${author}
 * @date ${date}
 */
@Service
@AllArgsConstructor
public class ${className}AppService {


    private final I${className}Service ${tableAliasName}Service;

    /**
     * 分页列表查询
     *
     * @param ${tableAliasName}Query 查询参数
     * @return 分页列表
     */
    public IPage<${className}VO> queryPage(${className}Query ${tableAliasName}Query) {
        return ${tableAliasName}Service.queryPage(${tableAliasName}Query);
    }

    /**
     * 保存/编辑
     *
     * @param ${tableAliasName} 业务参数
     * @return true/false
     */
    public Boolean saveOrUpdate(${className}DTO ${tableAliasName}) {
        return ${tableAliasName}Service.saveOrUpdate(BeanUtil.copy(${tableAliasName}, ${className}.class));
    }

    /**
     * 根据id查询一条明细
     *
     * @param id 主键
     * @return 明细
     */
    public ${className}VO detail(Long id) {
        if (StringUtils.isEmpty(id)) {
            return new ${className}VO();
        }
        return BeanUtil.copy(${tableAliasName}Service.getById(id), ${className}VO.class);
    }

    /**
     * 根据id删除一条数据，逻辑删除
     *
     * @param id 主键
     * @return true/false
     */
    public Boolean deleteById(Long id) {
        if (StringUtils.isEmpty(id)) {
            return Boolean.FALSE;
        }
        return ${tableAliasName}Service.removeById(id);
    }
}